package com.cx.mall.goods.controller;

import com.cx.mall.common.entity.goods.entity.SkuInfo;
import com.cx.mall.common.entity.order.model.Stock;
import com.cx.mall.common.util.ResponseVo;
import com.cx.mall.goods.service.ISkuInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 商品表 前端控制器
 * </p>
 *
 * @author zs
 * @since 2025-08-07
 */
@RestController
@RequestMapping("/goods/skuInfo")
public class SkuInfoController {
    @Autowired
    private ISkuInfoService skuInfoService;

    @PutMapping("/docount")
    public ResponseVo docount(@RequestBody Stock stock){
        skuInfoService.doCount(stock);
        return ResponseVo.success();
    }
    
    @GetMapping("/health")
    public ResponseVo<String> health(){
        return ResponseVo.success("mall-goods-service is running");
    }

    @GetMapping( "/listAll")
    public ResponseVo listAll(){
        List<SkuInfo> skuInfos = skuInfoService.list();
        return ResponseVo.success(skuInfos);
    }

}
